﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using ExtAspNet;

namespace HY.WEB.OA
{
    public partial class _review_view : PageBase
    {
        public string whe = "", stype = "";
        public string us ,bh;
        protected void Page_Load(object sender, EventArgs e)
        {  
            us=Session["ID"].ToString();
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["bh"]))
                {
                    bh = Request["bh"].ToString();

                    fill(bh);
                }
            }
        }

        private void fill(string bh)
        {
            DataTable dt1,dt2,dt3,dt4;

            dt1 = BLL.Bllbase.get_table("review_leave", "BH='" + bh + "'");
            dt2 = BLL.Bllbase.get_table("review_charge", "gbh='" + bh + "'");
            dt3 = BLL.Bllbase.get_table("review_out", "bh='" + bh + "'");
            dt4 = BLL.Bllbase.get_table("review_goods", "gbh='" + bh + "'");

            if (dt1.Rows.Count>0)
            {
                Lsdt.Visible = true;
                Ledt.Visible = true;
                Ldays.Visible = true;
                Lstype.Visible = true;

                Gitem.Visible = false;
                Gyyyymm.Visible = false;
                Gdt.Visible = false;
                Gsday.Visible = false;
                Gcmoney.Visible = false;
                Gchname.Visible = false;


                bbh.Text = dt1.Rows[0]["bh"].ToString();
                bname.Text = dt1.Rows[0]["sname"].ToString();
                Lsdt.Text = dt1.Rows[0]["sdt"].ToString();
                Ledt.Text = dt1.Rows[0]["edt"].ToString();
                Ldays.Text = dt1.Rows[0]["days"].ToString();
                Lstype.Text = dt1.Rows[0]["stype"].ToString();
                memo.Text = dt1.Rows[0]["remark"].ToString();
                SimpleForm1.Title = "请假单";

            }

            if (dt2.Rows.Count > 0)
            {
                SimpleForm1.Title = "报销单";
                Gitem.Visible = true;
                Gyyyymm.Visible = true;
                Gdt.Visible = true;
                Gsday.Visible = true;
                Gcmoney.Visible = true;
                Gchname.Visible = true;


                Lsdt.Visible = false;
                Ledt.Visible = false;
                Ldays.Visible = false;
                Lstype.Visible = false;

                bbh.Text = dt2.Rows[0]["gbh"].ToString();
                bname.Text = dt2.Rows[0]["pname"].ToString();
                Gitem.Text = dt2.Rows[0]["item"].ToString();
                Gyyyymm.Text = dt2.Rows[0]["dty"].ToString() + "-" + dt2.Rows[0]["dtm"].ToString();
                Gdt.Text = dt2.Rows[0]["dt"].ToString();
                Gsday.Text = dt2.Rows[0]["sday"].ToString();
                Gcmoney.Text = dt2.Rows[0]["cmoney"].ToString();
                Gchname.Text = dt2.Rows[0]["chname"].ToString();

                memo.Text = dt2.Rows[0]["remark"].ToString();
            }

            if (dt3.Rows.Count > 0)
            {
                Lsdt.Visible = true;
                Ledt.Visible = true;
                Ldays.Visible = true;
                Lstype.Visible = true;

                Gitem.Visible = false;
                Gyyyymm.Visible = false;
                Gdt.Visible = false;
                Gsday.Visible = false;
                Gcmoney.Visible = false;
                Gchname.Visible = false;


                bbh.Text = dt3.Rows[0]["bh"].ToString();
                bname.Text = dt3.Rows[0]["sname"].ToString();
                Lsdt.Text = dt3.Rows[0]["sdt"].ToString();
                Ledt.Text = dt3.Rows[0]["edt"].ToString();
                Ldays.Text = dt3.Rows[0]["days"].ToString();
                Lstype.Text = dt3.Rows[0]["stype"].ToString();
                memo.Text = dt3.Rows[0]["remark"].ToString();
                SimpleForm1.Title = "外出单";

            }


            if (dt4.Rows.Count > 0)
            {
                Lsdt.Visible = true;
                Ledt.Visible = true;
                Ldays.Visible = false;
                Lstype.Visible = false;

                Gitem.Visible = true;
                Gyyyymm.Visible = true;


                Gdt.Visible = true;
                Gsday.Visible = true;
                Gcmoney.Visible = true;
                Gchname.Visible = true;


                bbh.Text = dt4.Rows[0]["gbh"].ToString();
                bname.Text = dt4.Rows[0]["pname"].ToString();
                Gitem.Label = "物品名称";
                Gitem.Text = dt4.Rows[0]["item"].ToString();
                Gyyyymm.Label = "单位";
                Gyyyymm.Text = dt4.Rows[0]["unit"].ToString();
                Gdt.Label = "数量";
                Gdt.Text = dt4.Rows[0]["qty"].ToString();
                Gsday.Label = "单价";
                Gsday.Text = dt4.Rows[0]["price"].ToString();
                Gcmoney.Label = "金额";
                Gcmoney.Text = dt4.Rows[0]["total"].ToString();

                Lsdt.Label = "申请日期";
                Lsdt.Text = dt4.Rows[0]["edt"].ToString();
                Ledt.Label = "发放日期";
                Ledt.Text = dt4.Rows[0]["adt"].ToString();


                memo.Text = dt4.Rows[0]["remark"].ToString();

                Gchname.Label = "发放人";
                Gchname.Text = dt4.Rows[0]["rname"].ToString();

                SimpleForm1.Title = "物品领用单";
            }

          DataTable dt=  BLL.oa.leave_sub.getlist(bh);
          Grid2.DataSource = dt;
          Grid2.DataBind();

        }

        protected void Window1_Close(object sender, EventArgs e)
        {
            //Alert.Show("修改完成 ");
            PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
        }

    
    }
}
